<html>
<head>
<meta http-equiv="expires" content="Tue, 05 DEC 2000 07:00:00 GMT">
<meta http-equiv="Pragma" content="no-cache">
<script language=javascript src="util/Photoshop_APIWrapper.js"></script>
<script language=javascript>

   // Set some variables global to the SCO
   var rawScore = 0;
   var exitPageStatus = false;

   var _1 = "Pull down the Layer menu.";
   var _2 = "Click on Color Balance.";
   var _3 = "Adjust color levels by either using the slider bars or ";
   _3 += "changing the numerical values.";
   var _4 = "Point to New Adjustment Layer.";
   var _5 = "Check the Preview check box.";

   /**********************************************************************
   **  Function: reWrite()
   **  Description: This function is responsible populating the text box
   **               with the appropriate answer based on the number that
   **               the user enters.
   **********************************************************************/
   function reWrite( formValue, formToPopulate )
   {
      if (formValue == "1" )
      {
         formToPopulate.value = _1;
      }
      else if (formValue == "2" )
      {
         formToPopulate.value = _2;
      }
      else if (formValue == "3" )
      {
         formToPopulate.value = _3;
      }
      else if (formValue == "4" )
      {
         formToPopulate.value = _4;
      }
      else if (formValue == "5" )
      {
         formToPopulate.value = _5;
      }
      else if (formValue == "")
      {
         formToPopulate.value = "";
      }
      else
      {
         formToPopulate.value = "";
         msg = "You have entered an invalid value: [" + formValue + "]";
         msg += "\nPlease enter a number value between 1 and 5";
         alert(msg);
      }
   }

   /**********************************************************************
   **  Function: calcRawScore()
   **  Description: This function is responsible for incrementing the raw
   **               score (cmi.score.raw) if the question was 
   **               answered correctly.  If not, it keeps the raw score
   **               at its initial value (0).
   **********************************************************************/
   function calcRawScore()
   {
      rawScore = 0;
      
      if ( document.examForm.Q1.value == "1" && 
           document.examForm.Q2.value == "4" && 
           document.examForm.Q3.value == "2" && 
           document.examForm.Q4.value == "5" && 
           document.examForm.Q5.value == "3" )
      {
         rawScore++;
		} 
   }

   /**********************************************************************
   **  Function: calcScore()
   **  Description: This function is responsible for using the raw score
   **               set in "calcRawScore()" to determine the status of 
   **               the SCO.  The scaled score 
   **               (cmi.score.scaled), Success Status
   **               (cmi.success_status) and Completion Status
   **               (cmi.completion_status) are set appropriately.
   **               After each value is set, the SCO is finished with a
   **               call to Terminate().
   **********************************************************************/
   function calcScore()
   {
      // Disable the submit buttons so that it can not be clicked
      document.examForm.submitButton.disabled = true;
      
      // Get the raw score
      calcRawScore();
      
      //  Set the scaled score that will be used in the 
      //  Sequencing Tracking Model
      doSetValue( "cmi.score.scaled", rawScore );
      
      //  Indicate whether or not the attempt on the SCO was
      //  sucessful (passed or failed)
      if ( rawScore != 1 )
      {
         doSetValue( "cmi.success_status", "failed" );
      }
      else 
      {
         doSetValue( "cmi.success_status", "passed" );
      }
   
      //  Set the SCO to completed with a normal exit
      doSetValue( "cmi.completion_status", "completed" );
      doSetValue( "cmi.exit", "" );

      //  Indicate that the SCO was finished normally
      exitPageStatus = true;

      var result = doTerminate();
   }
    
   /**********************************************************************
   **  Function: loadPage()
   **  Description: This is called when a SCO is first loaded in the
   **               browser (onload()).  It finds the API if it was not
   **               already located and calls Initialize().  In
   **               the exitPageStatus global variable is set to false
   **               indicating that the SCO is not yet finished.
   **********************************************************************/
   function loadPage()
   {
      var result = doInitialize();
      exitPageStatus = false;
      
      // Get the header and subheader from the params
      g_params = new Array(10);
      get_params();
      mainHeader = g_params["main"];
      subHeader = g_params["sub"];

      var msg = "<h1><b>" + mainHeader + "</b></h1>"
      
      if ( subHeader != null)
      {
         document.all.disp.innerHTML = msg + "<h2><i>" + subHeader + "</i></h2>";
      }
      else
      {
         document.all.disp.innerHTML = msg;
      }
   }
   
   
   /**********************************************************************
   **  Function: doQuit()
   **  Description: This function is called in the case that the user
   **               does not finish the SCO "gracefully".  For example, 
   **               the user may click the "continue" button before
   **               submitting an answer to a question.  In this case,
   **               this function is called as part of the page unloading.
   **               This function ensures that Terminate() is called
   **               and that the correct statuses are set even if the 
   **               user closes the SCO window or navigates away before 
   **               finishing the SCO.
   **********************************************************************/
   function doQuit()
   {   
      calcScore();
   }

   
   /**********************************************************************
   **  Function: doQuit()
   **  Description: This function is called in the case that the user
   **               does not finish the SCO "gracefully".  For example, 
   **               the user may click the "continue" button before
   **               submitting an answer to a question.  In this case,
   **               this function is called as part of the page unloading.
   **               This function ensures that Terminate() is called
   **               even if the user closes the SCO window or navigates
   **               away before finishing the SCO.
   **********************************************************************/
   function unloadPage()
   {
    
   	if (exitPageStatus != true)
   	{
   		doQuit();
   	}
   
   	// NOTE: don't return anything that resembles a javascript
   	//		   string from this function or IE will take the
   	//		   liberty of displaying a confirm message box
   }
   
   /**********************************************************************
   **  Function: get_params()
   **  Description: This function is used to get the parameters from the
   **               query string
   **********************************************************************/
   function get_params()
   {
      var strSearch = window.location.search;
      var idx = strSearch.indexOf('?');
      if (idx != -1) 
      {
         var pairs = strSearch.substring(idx+1, strSearch.length).split('&');
         for (var i=0; i<pairs.length; i++) 
         {
            nameVal = pairs[i].split('=');
            g_params[nameVal[0]] = unescape(nameVal[1]);
         }
      }
   }

</script>
<title>Question</title>
</head>

<body onLoad="loadPage()" onunload="return unloadPage()">

   <div id="disp" name="disp"></div>   
   <br>
   <form name="examForm">
      How do you adjust the color balance of a photo? <i>Place the steps below 
      in the correct order.</i> 
      <p>
         1.  Pull down the Layer menu.<br>
         2.  Click on Color Balance.<br>
         3.  Adjust color levels by either using the slider bars or changing 
             the numerical values.<br>
         4.  Point to New Adjustment Layer.<br>
         5.  Check the Preview check box.</p>		
      <p>
      <input type="text" size="1" name="Q1" value="" 
       onKeyUp="reWrite(document.examForm.Q1.value,document.examForm.Answer1)"> 
      <input type="text" size="80" name="Answer1" value="" readonly><br>
      
      <input type="text"  size="1" name="Q2" value="" 
       onKeyUp="reWrite(document.examForm.Q2.value,document.examForm.Answer2)">
      <input type="text" size="80" name="Answer2" value="" readonly><br>
      
      <input type="text"  size="1" name="Q3" value="" 
       onKeyUp="reWrite(document.examForm.Q3.value,document.examForm.Answer3)">
      <input type="text" size="80" name="Answer3" value="" readonly><br>
      
      <input type="text" size="1" name="Q4" value="" 
       onKeyUp="reWrite(document.examForm.Q4.value,document.examForm.Answer4)"> 
      <input type="text" size="80" name="Answer4" value="" readonly><br>
      
      <input type="text"  size="1" name="Q5" value="" 
       onKeyUp="reWrite(document.examForm.Q5.value,document.examForm.Answer5)"> 
      <input type="text" size="80" name="Answer5" value="" readonly><br>
    
      <p> Correct Sequence: <i><b>1, 4, 2, 5, 3</b></i> </p>
    
      <input type="button" name="submitButton" value=" Submit Answer " 
             onClick="calcScore()">
   </form>
</body>

</html>